package com.dynaBlaster.containerTest;

import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;

import com.dynaBlaster.BoardView;
import com.dynaBlaster.DynaBlaster;
import com.dynaBlaster.DynaView;
import com.dynaBlaster.Point;
import com.dynaBlaster.DynaView.Area;

public class  ClearBoardTest extends BaseAndroidSuite {

	private DynaView board;

	public  ClearBoardTest() {
		super();
	}

	@Override
	public void setUp() throws Exception {
		super.setUp();

		DynaView.BOARD_CLEAR = true;

		board = mView;
		board.initWalls();
		board.initBoard();
	}

	public void testTest() {

		assertNotNull(board);

	}

	public void testBoardOnlyFreeAndConcrete() {
		for (int i = 0; i < board.mXTileCount; i++) {
			for (int j = 0; j < board.mYTileCount; j++) {
				int tile = board.getTile(new Point(i, j));
				if (!((tile == Area.CONCRETE.nr) || (tile == Area.FREE.nr))) {
					fail("tile not conrete or free" + tile + "x: " + i + "y:" + j);
				}
			}
		}

	}
	
	public void testExernalWallsVertical() {
			for (int j = 0; j < board.mYTileCount; j++) {
				int tile = board.getTile(new Point(0, j));
				if (! (tile == Area.CONCRETE.nr)  ) {
					fail("not external wall" + tile + "x: " + 0 + "y:" + j);
				}
				
				tile = board.getTile(new Point(board.mXTileCount-1, j));
				if (! (tile == Area.CONCRETE.nr)  ) {
					fail("not external wall" + tile + "x: " + (board.mXTileCount-1) + "y:" + j);
				}
			}
		}
	
	
	public void testExernalWallsHorisontal() {
			for (int i = 0; i < board.mXTileCount; i++) {
				int tile = board.getTile(new Point(i, 0));
				if (! (tile == Area.CONCRETE.nr)  ) {
					fail("not external wall" + tile + "x: " + i + "y:" + 0);
				}
				
				tile = board.getTile(new Point(i,board.mYTileCount-1));
				if (! (tile == Area.CONCRETE.nr)  ) {
					fail("not external wall" + tile + "x: " + i + "y:" + (board.mYTileCount-1));
				}
			}
		}

}